package structural_pattern.proxy_pattern;

public class ProxySearcher implements Searcher {

    private RealSearcher realSearcher = new RealSearcher();
    private AccessValidator validator;

    public Logger logger;

    @Override
    public String doSearch(String userId, String keyword) {
        if (validate(userId)) {
            String doSearch = realSearcher.doSearch(userId, keyword);
            this.log(userId);
            return doSearch;
         }
        return null;
}

public boolean validate(String useId) {
    validator = new AccessValidator();
    return validator.validate(useId);
}

public void log(String useId) {
    logger = new Logger();
    logger.log(useId);
}
}
